package com.gitee.jjnnzb.designpatterninspring.business.login.manager.impl;

import cn.hutool.core.util.IdUtil;
import com.gitee.jjnnzb.designpatterninspring.business.login.manager.LoginCheckManager;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * @author Jjn
 * @since 2023/8/9 21:03
 */
@Service
@Slf4j
public class LoginCheckManagerImpl implements LoginCheckManager {
    @Override
    public void checkSystemPermission(Map<String, Object> map) {
        String userName = (String) map.get("userName");
        String systemCode = (String) map.get("systemCode");
        if (log.isInfoEnabled()) {
            log.info("校验用户:{}有无对应系统:{}的访问权限中", userName, systemCode);
        }
    }
    
    @Override
    public void checkUserAndPassword(Map<String, Object> map) {
        String userName = (String) map.get("userName");
        String password = (String) map.get("password");
        if (log.isInfoEnabled()) {
            log.info("校验用户:{}密码:{}与数据库匹配", userName, password);
        }
        map.put("userId", IdUtil.objectId());
        map.put("orgId", IdUtil.simpleUUID());
    }
}
